#include <soar.h>

#define THRD_NUM		3

struct thrd_ctl
{/*{{{*/
    unsigned int thrd_id;
	int thrd_idx;
};/*}}}*/
static struct thrd_ctl a_thrd_ctl[THRD_NUM];

void *thrd_func(struct thrd_ctl *thrd_ctl)
{/*{{{*/
    int line=1;

    for(line=1; line<=20; line++)
    {
        filelog("Thread %d Line %d: Hello world!",
            thrd_ctl->thrd_idx, line);
        sleep(1);
    }

    return(0);
}/*}}}*/

int main(int argc, char *argv[])
{
    int thrd_idx;

//    filelog_create(argv[0], "");
//    filelog_create(argv[0], NULL);
    filelog_set_date_switch();

    for(thrd_idx=0; thrd_idx<THRD_NUM; thrd_idx++)
    {
		a_thrd_ctl[thrd_idx].thrd_idx=thrd_idx;
        if(thrd_create((THRD_FUNC_T)thrd_func,
                    (void *)&a_thrd_ctl[thrd_idx], 0,
                    &a_thrd_ctl[thrd_idx].thrd_id))
        {
            printf("thrd(%d) create fail\n", thrd_idx);
            return(-1);
        }
    }
    for(thrd_idx=0; thrd_idx<THRD_NUM; thrd_idx++)
    {
        thrd_join(a_thrd_ctl[thrd_idx].thrd_id);
    }

    return(0);
}
